#include "../../data/cl/lib/noise.cl"

constant real3	SCALE = (real3)( 1.0 );
constant real3	BIAS  = (real3)( 0.0 );

__kernel void TestEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = nc.x + nc.y * (real)(1.0e3) + nc.z * (real)(1.0e6);
	write_image( outImage, c.xy, value );
}

__kernel void BillowEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Billow( nc, DEFAULT_BILLOW_FREQUENCY, DEFAULT_BILLOW_LACUNARITY, DEFAULT_BILLOW_PERSISTENCE,
						  DEFAULT_BILLOW_QUALITY, DEFAULT_BILLOW_OCTAVE_COUNT, DEFAULT_BILLOW_SEED );
	write_image( outImage, c.xy, value );
}

__kernel void CheckerboardEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Checkerboard( nc );
	write_image( outImage, c.xy, value );
}
/*
__kernel void CurveEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Curve( nc, ... );
	write_image( outImage, c.xy, value );
}
*/
__kernel void CylindersEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Cylinders( nc, DEFAULT_CYLINDERS_FREQUENCY );
	write_image( outImage, c.xy, value );
}

__kernel void PerlinEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Perlin( nc, DEFAULT_PERLIN_FREQUENCY, DEFAULT_PERLIN_LACUNARITY, DEFAULT_PERLIN_PERSISTENCE,
						  DEFAULT_PERLIN_QUALITY, DEFAULT_PERLIN_OCTAVE_COUNT, DEFAULT_PERLIN_SEED );
	write_image( outImage, c.xy, value );
}

__kernel void RidgedMultiEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  weights[30];
	RidgedMulti_CalcSpectralWeights( DEFAULT_RIDGED_LACUNARITY, weights );
	real  value = RidgedMulti( nc, DEFAULT_RIDGED_FREQUENCY, DEFAULT_RIDGED_LACUNARITY, DEFAULT_RIDGED_QUALITY,
								DEFAULT_RIDGED_OCTAVE_COUNT, DEFAULT_RIDGED_SEED, weights );
	write_image( outImage, c.xy, value );
}

__kernel void SelectEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Select( nc, 0.5, 0.0, 1.0, DEFAULT_SELECT_LOWER_BOUND, DEFAULT_SELECT_UPPER_BOUND,
						  DEFAULT_SELECT_EDGE_FALLOFF );
	write_image( outImage, c.xy, value );
}

__kernel void SpheresEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Spheres( nc, DEFAULT_SPHERES_FREQUENCY );
	write_image( outImage, c.xy, value );
}
/*
__kernel void TerraceEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Terrace( nc, ... );
	write_image( outImage, c.xy, value );
}
*//*
__kernel void TurbulenceEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Turbulence( nc, DEFAULT_TURBULENCE_POWER, DEFAULT_TURBULENCE_FREQUENCY,
							  DEFAULT_TURBULENCE_ROUGHNESS, DEFAULT_TURBULENCE_SEED );
	write_image( outImage, c.xy, value );
}
*/
__kernel void VoronoiEntry (write_only image2d_t outImage)
{
	int3  c  = GetGlobalCoord();
	real3 nc = GetGlobalCoordTransformed( SCALE, BIAS );
	real  value = Voronoi( nc, DEFAULT_VORONOI_DISPLACEMENT, DEFAULT_VORONOI_FREQUENCY,
						   DEFAULT_VORONOI_SEED, false );
	write_image( outImage, c.xy, value );
}